/* 主题变量 - 优化后的色彩系统 */
:root {
    --color-bg: #f8f9fa;
    --color-fg: #1a1a1a;
    --color-muted: #6c757d;
    --color-card: #ffffff;
    --color-primary: #3b82f6;
    --color-primary-light: #93c5fd;
    --color-primary-dark: #2563eb;
    --color-primary-weak: rgba(59, 130, 246, 0.1);
    --color-secondary: #8b5cf6;
    --color-accent: #f43f5e;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-shadow: rgba(0,0,0,0.05);
    --color-shadow-hover: rgba(0,0,0,0.1);
    --color-border: #e5e7eb;
    --radius-s: 12px;
    --radius-m: 16px;
    --radius-l: 24px;
    --radius-full: 9999px;
    --elev-1: 0 2px 8px var(--color-shadow);
    --elev-2: 0 4px 15px rgba(0,0,0,0.08);
    --elev-3: 0 10px 25px rgba(0,0,0,0.12);
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* 基础样式重置和统一 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

body {
    background-color: var(--color-bg);
    color: var(--color-fg);
    line-height: 1.6;
    font-size: 16px;
    padding-bottom: calc(60px + env(safe-area-inset-bottom));
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

/* 顶部导航通用 - 增强版 */
.nav-bar {
    position: sticky;
    top: 0;
    background-color: var(--color-card);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--elev-1);
    z-index: 90;
    backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.95);
}

.logo {
    font-size: 24px;
    font-weight: 800;
    color: var(--color-fg);
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-btn {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    padding: 10px 18px;
    font-size: 14px;
    color: var(--color-muted);
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    gap: 6px;
}
.search-btn:hover {
    background: var(--color-primary-weak);
    border-color: var(--color-primary-light);
    color: var(--color-primary);
}

.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    transition: all var(--transition-normal);
}
.user-avatar:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

/* 底部导航通用 - 现代感增强 */
.tab-bar {
    position: fixed;
    bottom: 0;
    width: 100%;
    height: 60px;
    background-color: var(--color-card);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -4px 20px var(--color-shadow);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
    backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.95);
}
.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 12px;
    color: var(--color-muted);
    text-decoration: none;
    transition: all var(--transition-normal);
    padding: 6px 0;
    position: relative;
}
.tab-item.active {
    color: var(--color-primary);
}
.tab-item.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    width: 20px;
    height: 3px;
    background-color: var(--color-primary);
    border-radius: var(--radius-full);
}
.tab-icon {
    font-size: 24px;
    margin-bottom: 4px;
    transition: all var(--transition-normal);
}
.tab-item.active .tab-icon {
    transform: scale(1.2) translateY(-2px);
}

/* 容器与标题区通用 - 更现代的设计 */
.container {
    padding-bottom: 70px;
    padding-left: 16px;
    padding-right: 16px;
}
.header {
    padding: 24px 20px 16px;
    background-color: var(--color-card);
    background-image: linear-gradient(135deg, var(--color-primary-weak), var(--color-secondary) 120%);
    border-radius: 0 0 var(--radius-l) var(--radius-l);
    margin-bottom: 20px;
    box-shadow: var(--elev-2);
}
.app-title {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 10px;
    color: var(--color-fg);
    letter-spacing: -0.8px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.app-desc {
    font-size: 15px;
    color: var(--color-muted);
    max-width: 90%;
    line-height: 1.6;
}

/* 可滚动筛选条通用 - 增强版样式 */
.chip-scroll {
    padding: 16px 20px;
    background-color: var(--color-card);
    overflow-x: auto;
    white-space: nowrap;
    box-shadow: var(--elev-1);
    border-radius: var(--radius-m);
    margin: 0 16px 20px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.chip-scroll::-webkit-scrollbar {
    display: none;
}
.chip {
    display: inline-block;
    padding: 10px 20px;
    margin-right: 12px;
    border-radius: var(--radius-full);
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    user-select: none;
}
.chip::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background-color: rgba(59, 130, 246, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}
.chip:hover::after {
    width: 300px;
    height: 300px;
}
.chip:hover {
    background-color: var(--color-primary-weak);
    border-color: var(--color-primary-light);
}
.chip.active {
    background-color: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

/* 卡片通用 - 现代化设计 */
.card-grid {
    padding: 20px 16px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}
.card {
    background-color: var(--color-card);
    border-radius: var(--radius-l);
    overflow: hidden;
    box-shadow: var(--elev-2);
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    transform-origin: center;
    animation: fadeIn 0.5s ease-out;
}
.card:hover {
    transform: translateY(-8px) scale(1.03);
    box-shadow: var(--elev-3);
}
.card:active {
    transform: translateY(-4px) scale(0.98);
}
.media {
    position: relative;
    overflow: hidden;
    height: 160px;
}
.media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}
.card:hover .media img {
    transform: scale(1.15);
}
.overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 12px;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent 100%);
    opacity: 0;
    transition: opacity var(--transition-normal);
}
.card:hover .overlay {
    opacity: 1;
}
.overlay-text {
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    backdrop-filter: blur(4px);
}
.card-body {
    padding: 16px;
    text-align: center;
    background: linear-gradient(to bottom, transparent, var(--color-card) 30px);
}
.card-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--color-fg);
    transition: color var(--transition-normal);
    letter-spacing: -0.5px;
}
.card:hover .card-title {
    color: var(--color-primary);
}
.card-tag {
    font-size: 14px;
    color: var(--color-muted);
    background: var(--color-bg);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    display: inline-block;
    transition: all var(--transition-normal);
}
.card:hover .card-tag {
    background: var(--color-primary-weak);
    color: var(--color-primary);
}

/* 角标与收藏按钮通用 - 增强视觉效果 */
.badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: var(--color-warning);
    color: #fff;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 700;
    z-index: 10;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}
.fav-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    font-size: 18px;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.fav-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.15);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}
.fav-btn.active {
    color: var(--color-accent);
    background: rgba(244, 63, 94, 0.1);
    animation: heartBeat 0.6s ease;
}

@keyframes heartBeat {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* 列表类页面通用 - 现代化设计 */
.list {
    background-color: var(--color-card);
    border-radius: var(--radius-m);
    overflow: hidden;
    box-shadow: var(--elev-1);
    margin: 16px 0;
}
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}
.list-item:last-child {
    border-bottom: none;
}
.list-item:hover {
    background-color: var(--color-primary-weak);
    padding-left: 24px;
}
.list-item:active {
    background-color: var(--color-primary-weak);
}
.list-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: var(--color-primary);
    transform: scaleY(0);
    transition: transform var(--transition-normal);
}
.list-item:hover::before {
    transform: scaleY(1);
}

/* 输入框通用 - 增强版 */
.input {
    width: 100%;
    padding: 14px 18px;
    border-radius: var(--radius-s);
    border: 2px solid var(--color-border);
    background-color: var(--color-bg);
    font-size: 16px;
    outline: none;
    transition: all var(--transition-normal);
    position: relative;
    z-index: 1;
}
.input:focus {
    background-color: #fff;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px var(--color-primary-weak);
    transform: translateY(-1px);
}
.input::placeholder {
    color: var(--color-muted);
    font-weight: 400;
}

/* 响应式设计增强 */
@media (min-width: 480px) {
    .card-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
    .media {
        height: 180px;
    }
    .container, .search-content {
        padding-left: 24px;
        padding-right: 24px;
    }
}

@media (min-width: 768px) {
    .container, .search-content, .favorites-container {
        max-width: 1000px;
        margin: 0 auto;
        padding-left: 32px;
        padding-right: 32px;
    }
    .card-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 24px;
    }
    .media {
        height: 200px;
    }
    .nav-bar {
        padding-left: 32px;
        padding-right: 32px;
    }
}

/* 动画系统 - 增强版 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* 兼容原有类名（无需改HTML） */
.country-list { composes: card-grid; }
.country-card { composes: card; }
.flag-container { composes: media; }
.flag-img { composes: media img; }
.country-overlay { composes: overlay; }
.country-info { composes: card-body; }
.country-name { composes: card-title; }
.country-tag { composes: card-tag; }
.favorite-btn { composes: fav-btn; }
.featured-badge { composes: badge; }
.region-filter { composes: chip-scroll; }
.region-btn { composes: chip; }

/* 旧类名的最低限度fallback（当浏览器不支持 composes）*/
.country-list { padding: 16px 8px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.country-card { background-color: var(--color-card); border-radius: var(--radius-l); overflow: hidden; box-shadow: var(--elev-2); cursor: pointer; transition: all 0.3s ease; position: relative; transform-origin: center; animation: fadeIn 0.5s ease-out; }
.country-card:hover { transform: translateY(-5px) scale(1.02); box-shadow: 0 10px 25px rgba(0,0,0,0.12); }
.country-card:active { transform: translateY(-2px) scale(0.98); }
.flag-container { position: relative; overflow: hidden; height: 140px; }
.flag-container .flag-img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; }
.country-card:hover .flag-img { transform: scale(1.1); }
.country-overlay { position: absolute; bottom: 0; left: 0; right: 0; padding: 12px; background: linear-gradient(to top, rgba(0,0,0,0.7), transparent); opacity: 0; transition: opacity 0.3s ease; }
.country-card:hover .country-overlay { opacity: 1; }
.overlay-text { color: #fff; font-size: 12px; }
.country-info { padding: 16px 12px; text-align: center; }
.country-name { font-size: 18px; font-weight: 700; margin-bottom: 4px; color: var(--color-fg); transition: color 0.3s ease; }
.country-card:hover .country-name { color: var(--color-primary); }
.country-tag { font-size: 13px; color: var(--color-muted); background: var(--color-bg); padding: 4px 8px; border-radius: 12px; display: inline-block; }
.favorite-btn { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,0.8); border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.3s ease; font-size: 16px; z-index: 10; }
.favorite-btn:hover { background: rgba(255,255,255,1); transform: scale(1.1); }
.favorite-btn.active { color: #ff3b30; }
.featured-badge { position: absolute; top: 10px; left: 10px; background: #ff9500; color: #fff; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; z-index: 10; }
.region-filter { padding: 12px 16px; background-color: var(--color-card); overflow-x: auto; white-space: nowrap; box-shadow: 0 2px 5px rgba(0,0,0,0.03); border-radius: 12px; margin: 0 8px 16px; }
.region-btn { display: inline-block; padding: 8px 16px; margin-right: 10px; border-radius: 20px; background-color: var(--color-bg); border: none; font-size: 14px; cursor: pointer; transition: all 0.3s ease; position: relative; overflow: hidden; }
.region-btn::after { content: ""; position: absolute; top: 50%; left: 50%; width: 0; height: 0; border-radius: 50%; background-color: rgba(0,0,0,0.1); transform: translate(-50%, -50%); transition: width 0.6s, height 0.6s; }
.region-btn:hover::after { width: 300px; height: 300px; }
.region-btn.active { background-color: var(--color-primary); color: #fff; box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3); }

/* 首页动画延迟 */
.country-card:nth-child(1) { animation-delay: 0.1s; }
.country-card:nth-child(2) { animation-delay: 0.2s; }
.country-card:nth-child(3) { animation-delay: 0.3s; }
.country-card:nth-child(4) { animation-delay: 0.4s; }
.country-card:nth-child(5) { animation-delay: 0.5s; }
.country-card:nth-child(6) { animation-delay: 0.6s; }

